<template>
	<view class="hb">
		<image src="../../static/alihb_bg.png"  mode="" class="bg"></image>
		
		<view class="container">
			
		
			<view class="title">{{appName}}+支付宝</view>
			<view class="tips">{{appName}}用户每日都可领取此红包</view>
			
			<view class="info">
				<image src="../../static/ali_hb.png" class="info-bg" mode=""></image>
				<view class="code-box">
					
					<qrcode class="code" :val="codeUrl" :size="qrsize" ref="qrcode"></qrcode>
					<image src="../../static/code_hb.png" mode="" class="code-hb"></image>
				</view>
				
				<view class="desc">使用支付宝扫一扫</view>
				<view class="info-tips">领取大额红包</view>
				
				<view class="no">
					<input class="wrap__con__password" type="text" id="word" v-model="searchNo" readonly="readonly">
				</view>
				
				<view class="btn"  :data-clipboard-text="searchNo" @tap="copy()">复制并前往支付宝领取红包</view>
				
				<view class="btn-tips">(需下载好支付宝APP)</view>
			</view>
		
		</view>
		
	</view>
</template>


<script>


	import qrcode from '../../components/qrcode/qrcode.vue';
	import clipboard from 'clipboard';
	
	import {
		priceName, appName
	} from '../../common/config.js';
	
	export default{
		components: {
			qrcode
		},
		data() {
			return {
				searchNo: '',
				codeUrl: '',
				qrsize: 135,
			}
		},
		onLoad(options) {
			if(options.token){
				uni.setStorageSync('token', options.token);
			}
			this.searchNo = options.no;
			this.appName = appName;
			this.codeUrl = options.code;
			
		},
		onReady() {
			this.$refs.qrcode.creatQrcode();
		},
		methods: {
			copy() {
				// #ifdef H5
				var aa = new clipboard('.btn');
				aa.on('success', function(e) {
					console.info('Action:', e.action);
					console.info('Text:', e.text);
					console.info('Trigger:', e.trigger);
					uni.showToast({
						title:'复制成功'
					})
				
					e.clearSelection();
				});
					switch(uni.getSystemInfoSync().platform){
						case 'android':
						   console.log('运行Android上');
						   location.href = 'alipays://platformapi/startapp?saId=20001003';
						   break;
						case 'ios':
						   console.log('运行iOS上');
						   location.href = 'alipay://platformapi/startapp?saId=20001003';
						   break;
						default:
						   console.log('运行在开发者工具上')
						   break;
					}
				// #endif
				
				// #ifdef MP-WEIXIN
					uni.setClipboardData({
						data: this.detail.param_id,
						success: function () {
							Request.alert('复制成功，请打开支付宝 > 搜索粘贴');
						}
					});
				// #endif
				
			}
		}
	}
</script>

<style scoped>
	body, page{
		background: #2D50D0;
	}
	
	.bg{
		position: fixed;
		top: 0;
		left: 0;
		z-index: 0;
		width: 750upx;
		height: 1334upx;
	}
	
	.container{
		z-index: 2;
		position: relative;
		padding-top: 40upx;
	}
	
	.container>.title{
		color: #fff;
		font-size: 60upx;
		text-align: center;
	}
	
	.container>.tips{
		color: #C8DDF8;
		text-align: center;
	}
	
	.info{
		width: 600upx;
		height: 890upx;
		margin: 0 auto;
		position: relative;
		padding-top: 60upx;
		margin-top: 40upx;
	}
	
	.info .info-bg{
		width: 600upx;
		height: 890upx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 9;
	}
	
	.info>view{
		position: relative;
		z-index: 20;
		text-align: center;
	}
	
	.code-box{
		position: relative;
		z-index: 10;
		width: 270upx;
		height: 270upx;
		margin: 0 auto;
	}
	
	.code{
		width: 270upx;
		height: 270upx;
	}
	
	.code-hb{
		width: 50upx;
		height: 50upx;
		position: absolute;
		top: 110upx;
		margin: 0 auto;
		left: 0;
		right: 0;
	}
	
	.desc, .btn-tips{
		color: #F8C5BA;
		line-height: 60upx;
	}
	
	.info-tips{
		color: #FFC72F;
		font-size: 40upx;
		font-weight: 600;
	}
	
	.no{
		background: #fff;
		width: 300upx;
		margin: 60upx auto;
		padding: 10upx 0;
	}
	
	.btn{
		background: #FFC72F;
		width: 400upx;
		margin: 40upx auto;
		padding: 20upx 0;
		font-weight: 600;
	}
	
</style>
